//##############################################################################
//#    CuteWebshot is an application which can be used to render
//#    screenshots from webpages.
//#
//#    Copyright (C) 2010  Juhapekka Piiroinen
//#
//#    This program is free software: you can redistribute it and/or modify
//#    it under the terms of the GNU General Public License as published by
//#    the Free Software Foundation, either version 3 of the License, or
//#    (at your option) any later version.
//#
//#    This program is distributed in the hope that it will be useful,
//#    but WITHOUT ANY WARRANTY; without even the implied warranty of
//#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//#    GNU General Public License for more details.
//#
//#    You should have received a copy of the GNU General Public License
//#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//#############################################################################
//# Contact: juhapekka.piiroinen@gmail.com
//#############################################################################
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "common.h"
#include <QNetworkProxyFactory>
#include <QNetworkProxy>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QCoreApplication::setOrganizationName("Juhapekka Piiroinen");
    QCoreApplication::setOrganizationDomain("jpii.fi");
    QCoreApplication::setApplicationName("CuteWebshot");

    MainWindow w;
    DEBUG << "Detecting platform proxy settings..";
    QList<QNetworkProxy> proxyList = QNetworkProxyFactory::systemProxyForQuery();
    foreach (QNetworkProxy proxy, proxyList) {
        DEBUG << proxy.hostName() << proxy.port();
    }
    DEBUG << "..proxies detected!";

    DEBUG << "argument count:" << a.arguments().count();
    DEBUG << "Command line arguments:" << a.arguments().join(" ");
    if (a.arguments().count()!=2) {
        DEBUG << "USAGE:" << QApplication::applicationName() << "[url]";
        return -1;
    }
    w.showMinimized();
    w.setUrl(a.arguments().at(1));
    return a.exec();
}
